#ifndef IMAGEOBJECT_H_INCLUDED
#define IMAGEOBJECT_H_INCLUDED

#include <string>
#include "BaseObject.h"
#include <Math/Rect.hpp>
/**
 *	ImageObject is an data container obj for OpenGL textures.
 *	ImageObjects can't be drawn directly.
 */
class ImageObject : public BaseObject
{
public:
	/**
	 * MEMORY allocation
	 */
	static boost::pool<boost::default_user_allocator_malloc_free> pool;
	void * operator new(size_t size);
	void operator delete(void * ptr);

	/**
	 * Construct a BaseObject
	 */
	ImageObject();

	/**
	 * Destructor
	 */
    virtual ~ImageObject();

    /**
     *	TYPE OF the object, See ObjectSubSystem.h */
	virtual int objectType();

	// Loads image from file.
	void load(std::string file);

	// Creates completly new texture or refences existing one.
	BaseObject * copy(int flags);

	void getTexID();	// get raw OpenGL texture id
	void getCheckID();	// each created ImageObject is applied with 'cheking id'.

	cvMath::Vec2i getDimensions();
private:
	int m_refencecount;
	GLuint m_texID;
	size_t m_checkid;

	RGBAi * m_raw_data;
	cvMath::Recti m_texture_bounds;
	size_t m_width, m_height;
};

#endif // IMAGEOBJECT_H_INCLUDED
